package com.lhj.bootdemo.designmode.single;

/**
 * @author lhj
 * @version 1.0
 * @date 2022/5/10 11:21 上午
 * @description: 枚举的单例模式
 */

enum Singleton {

    /**
     * 枚举值的默认修饰符public static final
     */
    INSTANCE;

    public String name;

    public volatile Integer count = 0;

    /**
     * 枚举类的构造方法使用private 修饰
     */
    Singleton() {
    }

    Singleton(String name) {
        this.name = name;
    }

    public void sayOk() {
        System.out.println("abc");
    }


    public void add() {
        count++;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }
}
